﻿using UnityEngine;
using System.Collections;

public class Camera : MonoBehaviour
{
	public float smoothMovement = 3.0f;
	public Transform playerRefence;
	private Transform myTransform;
	
	private void Awake ()
	{
		myTransform = transform;
	}
	
	Vector3 GetPlayerPosition ()
	{
		return new Vector3 (playerRefence.position.x, // get X from player
		                    playerRefence.position.y, // get Yfrom player
		                    myTransform.position.z);  // get X from camera
	}

	void Update ()
	{
	
		Vector3 newPosition = GetPlayerPosition ();
		
		// Interpolate camera position to player
		myTransform.position = Vector3.Lerp (myTransform.position, newPosition, smoothMovement * Time.deltaTime);
	}
}
